package com.william.lifetraxer.util;

import java.util.List;

import static com.william.lifetraxer.util.Values.*;

public class UserDAO {
	
	public static int insertUser(User user)
	{
		String insertString = "insert into " + dbUserTable +" (username,password) value(?,?)";
		return DbManager.insertUserDb(insertString,user);
	}
	
	public static int resetPassword(User user , String newPassword)
	{
		String updateString = "update " + dbUserTable + " set password = ? where userid = ? ";
		return DbManager.resetPasswordDb(updateString , user , newPassword);
	}
	
//	maybe valid
	public static User getUser(int userid)
	{
		String queryString = "select username from " + dbUserTable + " where userid = ? ";
		return DbManager.getUserDb(queryString,userid);
	}
	
	public static List<User> getOnlineUsers()
	{
		String queryString = "select username from " + dbUserTable + " where statu = ? ";
		return DbManager.getOnlineUsersDb(queryString,1);
	}
}
